import { ref } from "vue";
import LocalCache from "@/utils/storage";
export let isDark = ref<Boolean>(false);

export const setTheme = (type: string) => {
  if (type === "dark") {
    isDark.value = true;
    document.body.setAttribute("arco-theme", "dark");
    LocalCache.set("theme", "dark");
    return;
  }
  isDark.value = false;
  LocalCache.set("theme", "");
  document.body.removeAttribute("arco-theme");
};

export const loadTheme = () => {
  const theme = LocalCache.get("theme");
  theme ? setTheme(theme) : setTheme("");
};
